package net.liteheaven.dtimer.timer

import android.app.Service
import android.content.Context
import android.os.PowerManager

/**
 * Created by LiangYu on 2018/8/1.
 */
object WakeLockUtil{

    fun lock(context: Context, wakeLockTag: String): PowerManager.WakeLock{
        val pm = context.getSystemService(Service.POWER_SERVICE) as PowerManager
        val wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, wakeLockTag)
        wakelock.acquire()
        return wakelock
    }

    fun unlock(wakeLock: PowerManager.WakeLock){
        wakeLock.release()
    }
}